const helper={};

//变化大小
helper.resize=function(el,resizeType,moveXY,currentXY){     
    var x=moveXY.x-currentXY.x;
    var y=moveXY.y-currentXY.y;
    
    if(resizeType === 'top' &&  el.y + y >= 0 && el.height-y>5){
        el.height=el.height-y;
		el.y = el.y+y;
    }else if(resizeType === 'left-top' && el.x+x>=0 &&  el.y + y >= 0 && el.width-x>5 && el.height-y>5){   
        el.width=el.width-x;        
        el.x=el.x+x;
        el.height=el.height-y;
        el.y = el.y+y;
    }else if(resizeType === 'right-top' && el.width+x <= el.pageSize.width-el.x &&  el.y + y >= 0 && el.width+x>5 && el.height-y>5){        
        el.width=el.width+x;  
        el.height=el.height-y;
        el.y = el.y+y;
    }else if(resizeType === 'right' && el.width+x <= el.pageSize.width-el.x && el.width+x>5){
        el.width=el.width+x;  
    }else if(resizeType === 'right-bottom' && el.width+x <= el.pageSize.width-el.x && el.height+y <= el.pageSize.height-el.y && el.width+x>5 && el.height+y>5){
        el.width=el.width+x;  
        el.height=el.height+y;
    }else if(resizeType === 'bottom' && el.height+y <= el.pageSize.height-el.y && el.height+y>0){
        el.height=el.height+y;
    }else if(resizeType === 'left-bottom' && el.x + x >= 0 && el.height+y <= el.pageSize.height-el.y && el.width - x >5 && el.height + y > 5){
        el.x=el.x + x;
        el.width=el.width - x;       
        el.height=el.height + y;
    }else if(resizeType === 'left' && el.x + x >= 0 && el.width - x>5){
        el.x=el.x + x;
        el.width=el.width - x; 
    }
}

helper.svgClickXY=function(page,event){    
    // var element=document.querySelector('.page');
   // console.log('svgClickXY:',event,`{x:${event.layerX+element.scrollLeft},y:${event.layerY+element.scrollTop}}`)
    //return {x:event.layerX+element.scrollLeft,y:event.layerY+element.scrollTop};
    return {x:event.offsetX,y:event.offsetY};
}

helper.clone=function(obj){
    return JSON.parse(JSON.stringify(obj));
}
export default helper;